import Vue from 'vue'
import VueRouter from 'vue-router'
import login from '../mianjing/login.vue'
import register from '../mianjing/register.vue'
import layout from '../mianjing/layout.vue'
//二级路由
import article from '../mianjing/sub/artilce.vue'
import collect from '../mianjing/sub/collect.vue'
import like from '../mianjing/sub/like.vue'
import my from '../mianjing/sub/my.vue'



Vue.use(VueRouter)

//路由规则配置
const routes = [
  //一个路径对应一个组件
  {
    path: '/login',
    name: 'login',
    component: login
  },
  {
    path: '/register',
    name: 'register',
    component: register
  },

  {
    path: '/layout',
    name: 'layout',
    component: layout,
    redirect: '/layout/home',
    children: [
      /**
     1.如果写了/,那就跟一级路由地址没有关系,
     如果没有写,那就会和一级路由地址进行拼接
    2.如果子路由path,没有添加/,那么重定向中需要加上/layout来表示
    是谁的子路由,在router-link的to属性中,也需要拼接完整路由地址
 **/
      {
        path: 'home',
        name: '面经',
        component: article,
      },
      {
        path: 'collect',
        name: '收藏',
        component: collect,
      },
      {
        path: 'like',
        name: '喜欢',
        component: like,
      },
      {
        path: 'my',
        name: '我的',
        component: my,
      },
    ]
  },



]

const router = new VueRouter({
  mode: 'hash',//配置路由模式
  routes,

})

export default router
